package com.bolt.common.ognl;

import com.bolt.common.reflect.ClassLoaderUtil;
import ognl.ClassResolver;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/10.
 */

public class OgnlClassResolver implements ClassResolver {

    private Map <String, Class <?>> classes = new HashMap <String, Class <?>>(101);

    @Override
    public Class classForName(String className, Map context) throws ClassNotFoundException {
        Class <?> result = null;
        if ((result = classes.get(className)) == null) {
            result = ClassLoaderUtil.loadClass(className);
            classes.put(className, result);
        }
        return result;
    }
}

